package com.superteam.mac.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;

import com.superteam.mac.mode.IndexConfig;

public class IndexConfigDAO extends BaseDAO {

	@SuppressWarnings("unchecked")
	public List<IndexConfig> findAllIndexConfig()
	{
		String sql = "select * from tbindexconfig ";
		List<IndexConfig>  list = this.getJdbcTemplate().query(
			   sql,
			    new RowMapper() {

			        public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
			        	IndexConfig confg = new IndexConfig();
			        	confg.setIndexName(rs.getString("IndexName"));
			        	confg.setModeType(rs.getString("ModelType"));
			        	confg.setIndexUnit(rs.getString("IndexUnit"));
			        	confg.setLowerVal(rs.getDouble("LowerVal"));
			        	confg.setUpperVal(rs.getDouble("UpperVal"));
			        	confg.setSwitchFormula(rs.getString("SwitchFormula"));
			        	
			            return confg;
			        }
			    });
		return list;
	}
}
